/*
 * Copyright 2011 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class DBtest implements EntryPoint {
	private Button clickMeButton;
	private TextBox textBox;
	public void onModuleLoad() {
		RootPanel rootPanel = RootPanel.get();

		clickMeButton = new Button();
		rootPanel.add(clickMeButton, 66, 148);
		clickMeButton.setText("add to db");
		rootPanel.add(getTextBox(), 59, 80);
		clickMeButton.addClickHandler(new ClickHandler(){
			public void onClick(ClickEvent event) {
				GameRemote.Util.getInstance().addNewPlayer(getTextBox().getSelectedText(), new AsyncCallback<Void>() {
					
					@Override
					public void onSuccess(Void result) {
						Window.alert("El7amd llah");
						
					}
					
					@Override
					public void onFailure(Throwable caught) {
						Window.alert("Mesh shaghalah A7aaaaaaaaaaa");
						
					}
				});
			}
		});
	}
	private TextBox getTextBox() {
		if (textBox == null) {
			textBox = new TextBox();
			textBox.setSize("309px", "38px");
		}
		return textBox;
	}
}
